home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / hopes_babysitting_maze.swf / scripts / __Packages / smashing / SoundEngine.as < prev   
Text File  |  2011-08-19  |  3KB  |  98 lines

  1. class smashing.SoundEngine
  2. {
  3.    var DEFAULTMCNAME = "soundEngine_MC";
  4.    var DEFAULTGROUPNAME = "sound";
  5.    function SoundEngine(t_path, t_depth, t_overwrite)
  6.    {
  7.       this.mc = t_path.createEmptyMovieClip(this.DEFAULTMCNAME,t_depth);
  8.       this.o_sounds = new Object();
  9.       this.o_groups = new Object();
  10.       if(t_overwrite == undefined)
  11.       {
  12.          t_overwrite = false;
  13.       }
  14.       this.flagOverwrite = t_overwrite;
  15.       this.groupCount = 0;
  16.       this.createGroup(this.DEFAULTGROUPNAME);
  17.       trace("-- Init Sound Engine -- ");
  18.    }
  19.    function createGroup(t_name)
  20.    {
  21.       this.groupCount = this.groupCount + 1;
  22.       var _loc2_ = this.mc.createEmptyMovieClip(t_name,this.groupCount);
  23.       _loc2_.soundObject = new Sound(_loc2_);
  24.       this.o_groups[t_name] = _loc2_;
  25.    }
  26.    function createSound(t_name, t_assetID, t_group)
  27.    {
  28.       var _loc3_ = undefined;
  29.       if(t_group == undefined)
  30.       {
  31.          _loc3_ = this.o_groups[this.DEFAULTGROUPNAME];
  32.       }
  33.       else
  34.       {
  35.          _loc3_ = this.o_groups[t_group];
  36.       }
  37.       if(_loc3_ != undefined)
  38.       {
  39.          var _loc2_ = {};
  40.          _loc2_.soundEffect = new Sound(_loc3_);
  41.          _loc2_.soundEffect.attachSound(t_assetID);
  42.          this.o_sounds[t_name] = _loc2_;
  43.       }
  44.       else
  45.       {
  46.          trace("Error Locating Group " + t_group + " for create Sound");
  47.       }
  48.    }
  49.    function playSound(t_name, t_loops)
  50.    {
  51.       if(this.muted)
  52.       {
  53.          return undefined;
  54.       }
  55.       var _loc3_ = this.o_sounds[t_name];
  56.       if(_loc3_ != undefined)
  57.       {
  58.          if(t_loops == undefined)
  59.          {
  60.             t_loops = 1;
  61.          }
  62.          else if(t_loops == 0)
  63.          {
  64.             t_loops = 1000;
  65.          }
  66.          if(_global.K_SoundEngine.OverwriteSounds)
  67.          {
  68.             _loc3_.SoundEffect.stop(_loc3_.idName);
  69.          }
  70.          _loc3_.soundEffect.start(0,t_loops);
  71.       }
  72.       else
  73.       {
  74.          trace("Error - sound " + t_name + " not found");
  75.       }
  76.    }
  77.    function stopSound(t_name)
  78.    {
  79.       this.o_sounds[t_name].soundEffect.stop();
  80.    }
  81.    function changeVolume(t_vol, t_groupName)
  82.    {
  83.       if(t_groupName == undefined)
  84.       {
  85.          t_groupName = this.DEFAULTGROUPNAME;
  86.       }
  87.       this.o_groups[t_groupName].soundObject.setVolume(t_vol);
  88.    }
  89.    function soundOff()
  90.    {
  91.       this.muted = true;
  92.    }
  93.    function soundOn()
  94.    {
  95.       this.muted = false;
  96.    }
  97. }
  98.